import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import { LOAD_SELECTED_PRODUCTION_DATA } from '../actions/PublicationActions';

const initialState = {
    error: null,
    productionData: {}
}

const persistConfig = {
    key: 'publication',
    storage,
    whitelist: ['productionData'], // place to select which state you want to persist
}

const publicationReducer = (state = initialState, action) => {
    switch (action.type) {
        case LOAD_SELECTED_PRODUCTION_DATA:
            return {
                ...state,
                productionData: action.data,
            }
        default:
            return {...state};
    }
};

export default persistReducer(persistConfig, publicationReducer);